package model

import (
	"gorm.io/gorm"
	"time"
	"user_service/global"
)

type UserHome struct {
	Id        uint           `gorm:"column:id;type:bigint UNSIGNED;primaryKey;not null;" json:"id"`
	Title     string         `gorm:"column:title;type:varchar(20);not null;" json:"title"`
	Describe  string         `gorm:"column:describe;type:varchar(20);not null;" json:"describe"`
	VideoUrl  string         `gorm:"column:video_url;type:varchar(100);not null;" json:"video_url"`
	CreatedAt time.Time      `gorm:"column:created_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"created_at"`
	UpdatedAt time.Time      `gorm:"column:updated_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);default:NULL;" json:"deleted_at"`
}

func (u *UserHome) TableName() string {
	return "user_home"
}

func (u *UserHome) List() (list []*UserHome, err error) {
	err = global.DB.Find(&list).Error
	if err != nil {
		return
	}
	return nil, err
}
